<!-- 任务执行情况 -->
<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>每日餐品类目</span>
        <span class="el-icon-circle-close close-Btn-line" @click="checkVideoStatus"></span>
      </div>
      <div class="commentBody">
        <el-form ref="infoForm" label-width="90px">
          <div class="foodList-box">
            <el-form-item :label="`${item.name}:`" v-for="(item,index) in typelist" :key="index">
              <el-switch
                  v-model="item.status"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  active-text="开启"
                  inactive-text="关闭"
                  @change="changeSwitch(index)">
              </el-switch>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="checkVideoStatus" size="small">返回</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import {dishTypeindex, dishTypeEdit} from '@/api/admin/food.js'

export default {
  name: 'food',
  props: ['visible'],
  components: {},
  data() {
    return {
      dialogVisible: this.visible,
      typelist: []
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.getTypeListFn()
      } else {
        this.typelist = []
      }
    }
  },
  created() {

  },
  methods: {
    getTypeListFn() {
      dishTypeindex().then(res => {
        for (let item of res.list) {
          item.status = item.status === 1 ? true : false
        }
        this.typelist = res.list
      })
    },
    changeSwitch(index) {
      dishTypeEdit({id: this.typelist[index].id, status: this.typelist[index].status ? 1 : 0}).then(res => {
        if(!res.code){
          this.$message.success(res.msg)
        }else{
          this.$message.error(res.msg)
        }
      })
    },
    // 关闭
    checkVideoStatus() {
      this.$emit('update:visible', false)
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 350px;
  height: 350px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.footer-release {
  padding: 20px 0 0;
  min-height: 400px;
}

.last-day-list-box {
  padding: 20px 0 0;
  max-height: 460px;
  overflow-y: auto;
}

.last-day-list-box-body {
  border: 1px solid #000;
  border-radius: 6px;
  cursor: pointer;
  width: 100px;
  float: left;
  margin-right: 20px;
  color: #333;
  margin-bottom: 20px;
  position: relative;
}

.last-day-list-box-body:hover {
  box-shadow: 0 0 14px #1b8de5;
}

.close-btn-foot {
  position: absolute;
  top: -15px;
  right: -15px;
  color: red;
  font-size: 30px;
  width: 30px;
  height: 30px;
  line-height: 30px;
  margin: 0;
}

.last-day-list-box-img {
  width: 98px;
  height: 98px;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;

}

.last-day-list-box-title {
  text-align: center;
  color: #000;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foodList-box {
  max-height: 400px;
  overflow-y: auto;
}
</style>
